package com.example.seed.util;

import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;

/**
 * Created by lianbone on 2019/9/3.
 * Desc: 时间工具
 */
public class DateTimeUtil {

    /**
     * 常见格式转换
     *
     * @param dateStr
     * @return
     */
    public static DateTime parseDateTime(String dateStr) {
        try {
            return new DateTime(dateStr);
        } catch (Exception ignored) {
        }
        try {
            DateTimeFormatter dateTimeFormatter = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss");
            return DateTime.parse(dateStr, dateTimeFormatter);
        } catch (Exception ignored) {
        }
        return null;
    }
}
